<?php
require('../conn.php');
require('../functions.php');
require('admin.php');
$page = $_GET['page'];
if (is_numeric($page) == false) {
    $page = 1;
    $page_1 = 1;
    $min = 0;
    $page_2 = $page + 1;
} else {
    if ($page > 1) {
        $page_2 = $page + 1;
        $min = ($page - 1) * 35;
        $page_1 = $page - 1;
    } else {
        $page_1 = 1;
        $min = 0;
        $page_2 = 2;
    }
}
$max = $page * 35;
$sql = "select * from user limit $min,$max";
if ($_GET['do'] == 'search') {
    $phone = guolv($_GET['phone']);
    if (substr($phone, 0, 1) == '#') {
        $search_id = str_replace('#', '', $phone);
        $sql = "select * from `user` where `id`='{$search_id}' order by `id` desc limit {$min},{$max}";
    }
} else if ($_GET['do'] == 'score') {
    $sql = "select * from user ORDER BY score DESC limit $min,$max";
}
$row_user = $mysql->query($sql);
?>

<?php include('head.php') ?>
<div class="container-fluid">
    <div class="row-fluid">
        <?php
        include('left.php'); ?>
        <div class="span9">
            <h1 class="page-title">会员积分明细</h1>

            <div class="well">
                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane active in" id="home">
                        <div class="well">
                            <form class="navbar-search pull-left" action="user_score_detail.php" method="get">
                                <input type="hidden" name="do" value="search">
                                <input type="text" class="search-query" placeholder="#+id搜索会员" name="phone">
                            </form>
                            <div class="pull-right">
                                <a href="user_score_detail.php" class="btn">首页</a></button>
                                <a href="user_score_detail.php?page=<?php echo $page_1 ?><?php if($_GET['do']=='score') echo "&do=score"?>" class="btn"
                                   style="margin-left:5px;">上一页</a>
                                <a href="user_score_detail.php?page=<?php echo $page_2 ?><?php if($_GET['do']=='score') echo "&do=score"?>" class="btn"
                                   style="margin-left:5px;">下一页</a>
                            </div>
                            <table class="table">
                                <thead>
                                <tr>
                                    <th>#</th>
                                    <th>用户名</th>
                                    <th><a href="?do=score">总积分</a></th>
                                    <th>点赞</th>
                                    <th>评论</th>
                                    <th>发表</th>
                                    <th>阅读</th>
                                    <th>徒弟贡献</th>
                                    <th>赠送</th>
                                    <th>其他</th>
                                    <th>接受积分</th>
                                    <th>徒弟登录</th>
                                    <th>空间分享</th>
                                    <th>朋友圈分享</th>
                                    <th>徒弟金币贡献</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php
                                $i = 1;
                                foreach ($row_user as $user) {
                                    $jinfo = $mysql->query("select * from `jhi_user_authority` where `user_id` = {$user['id']}");
                                    $val = $jinfo[0];
                                    ?>
                                    <tr>
                                        <td><?= $val['user_id'] ?></td>
                                        <td><?= $user['name']?></td>
                                        <td><?=$user['score']?></td>
                                        <td><?= $val['praise'] ?></td>
                                        <td><?= $val['comment'] ?></td>
                                        <td><?= $val['publish'] ?></td>
                                        <td><?= $val['read'] ?></td>
                                        <td><?= $val['student'] ?></td>
                                        <td><?= $val['send'] ?></td>
                                        <td><?= $val['other'] ?></td>
                                        <td><?= $val['receiver'] ?></td>
                                        <td><?= $val['student_login'] ?></td>
                                        <td><?= $val['share_article'] ?></td>
                                        <td><?= $val['share_friend'] ?></td>
                                        <td><?= $val['student_gold'] ?></td>
                                    </tr>
                                <?php } ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="tab-pane fade" id="profile">
                    </div>
                </div>

            </div>

        </div>
    </div>


</div>
<script src="lib/bootstrap/js/bootstrap.js"></script>


</body>
</html>